package org.rayson.server;

import java.util.Properties;
import java.util.concurrent.LinkedBlockingQueue;

import org.rayson.api.server.ServerRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RequestManager implements Manager {
	private static final Logger LOGGER = LoggerFactory
			.getLogger(RequestManager.class);
	private final Container container;

	private final LinkedBlockingQueue<ServerRequest> requests;

	/**
	 * @param container
	 */
	public RequestManager(final Container container) {
		this.container = container;
		requests = new LinkedBlockingQueue<ServerRequest>();
	}

	public void add(final ServerRequest request) {
		LOGGER.debug("Add request " + request);
		requests.add(request);
	}

	@Override
	public Container getContainer() {
		return this.container;
	}

	@Override
	public String getName() {
		return "Request Manager of " + container.getName();
	}

	@Override
	public void start(final Properties properties) {
		// TODO Auto-generated method stub

	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub

	}

	public ServerRequest take() throws InterruptedException {
		return requests.take();
	}
}